<template>
    <div class="forward">
        <div class="header padding-24 space-between bg-active">
            <div class="h-back">
                <p class="fs-32 color-f" @click="cancel">取消</p>
            </div>
            <div class="title fs-36 color-f">转发</div>
            <div class="h-right">
                <p class="fs-32 color-f" @click="publick">发布</p>
            </div>
        </div>
        <div class="texts padding-24">
            <textarea name="" placeholder="请输入你的观点..." v-model="text"></textarea>
        </div>
    </div>
</template>
<script>
export default {
    data(){
        return{
            dynamicDetails:'',
            text:''
        }
    },
    created(){
        this.getdynamicDetails()
    },
    methods:{
        getdynamicDetails(){
            let url = this.$host1 + `home/dynamic/videoInfo`
            this.$axios.get(url,{
                params:{
                    dynamic_id:this.$route.query.id,
                }
            }).then(res => {
                console.log(res)
                //return
                if (res.status == 200) {
                let resData = res.data;
                if (resData.code == 200) {
                    //this.dynamiclist=resData.data.result
                    this.dynamicDetails=resData.data
                }else{
                    this.AlertWin(resData.message);
                }
                }
            }).catch(() => {
                this.AlertWin("网络错误！请稍后重试！");
            });
        },
        cancel(){
            this.$router.go(-1)
        },
        publick(){
            var data={
                dynamic_id:this.$route.query.id,
                viewpoint:this.text,
                original_dynamic_user_id:this.dynamicDetails.user_id,
                dynamic_type:3,
                content:this.dynamicDetails.content,
                video_url:this.dynamicDetails.video_url,
                image_url:this.dynamicDetails.image_url,
                music_id:this.dynamicDetails.music_id,
                video_cover:this.dynamicDetails.video_cover,
                video_status:0,
            }
            const url = this.$host1 + `home/dynamic/publishDynamic`;
            console.log(data)
            //return
            this.$axios.post(url,data).then(res=>{
                console.log(res);
                if(res.status == 200){
                    let resData = res.data;
                    if(resData.code==10002){
                        this.common.AlertWin(resData.msg)
                        setTimeout(() => {
                        this.$router.push('/login')
                        }, 2000)
                    }else if(resData.code==200){
                        this.common.AlertWin('发布成功！')
                        setTimeout(()=>{
                            this.$router.go(-1)
                        },1000)
                        
                    }else{
                        this.common.AlertWin(resData.message)
                    }
                   
                }else{
                    this.common.AlertWin('网络错误！请稍后重试！')
                }
            }).catch(() => {
                this.AlertWin("网络错误！请稍后重试！");
            });
        }
    }
}
</script>
<style lang="scss" >
.forward{
    width: 100%;
    height: 100%;
    position: absolute;
    padding-top: 1rem;
    box-sizing: border-box;
    background-color: #fff;
    .header{
      width: 100%;
      height: 1rem;
      
      .title{
          font-size: 0.36rem;
          font-weight: bold;
      }
      
      
    }
    .texts{
        padding-top: 0.2rem;
        width: 100%;
        height: 3rem;
        textarea{
            width: 100%;
            height: 100%;
            border: none;
            outline: none;
            font-size: 0.32rem;
        }
    }
}
</style>